<?php
namespace App\Http\Controllers\ApiWx\Mys;

use App\DBs\FarmDB;
use Illuminate\Http\Request;

class FarmController extends BaseController
{
    //视频

    protected $db;

    public function __construct()
    {
        parent::__construct();
        $this->db = new FarmDB();
    }

    /**
     * 果树列表
     */
    public function getTreeIndex(Request $request)
    {
        $wx = $request->post('wx','');
        if (!$wx) {
            return $this->toWxJson(-2);
        }
        $resDb = $this->db->getTreeIndex($wx);
        if ($resDb['code']==-2) {
            return array('code'=>'-5','msg'=>'已领取或者已申请');
        } else if ($resDb['code']!=0) {
            return $this->toWxJson(-500);
        }
        $items = $resDb['data']; $total = $resDb['total'];
        return $this->toWxJson(0,$items,$total);
    }
}